const Log = require('../models/log');


function list(req, res, next){
    return Log.aggregate({
        $match: {
            
        }
    },
    {
        $group: {
            _id: '$user',
            amount: {$sum: 1},
            duration: {$sum: '$duration'}
        }
    }
    // {

    //     $project: {
    //         user: 1
    //     }

    // },
    ).then((result)=>{
        res.json(result||[]);
    }).catch((error)=>{
        console.log(error);
        res.status(500);
        res.end();
    })
}

module.exports = {
    list
}